package com.ycky.common.core.page;


import com.ycky.common.utils.StringUtils;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;

/**
 * @description: 分页数据
 * @author: cjj
 * @date: 2025/3/20 13:24
 **/
@Setter
@Data
public class PageDomain {
    /**
     * 当前记录起始索引
     */
    private Integer pageNum;

    /**
     * 每页显示记录数
     */
    private Integer pageSize;

    /**
     * 排序列
     */
    @Getter
    private String orderByColumn;

    /**
     * 排序的方向desc或者asc
     */
    @Getter
    private String isAsc = "asc";

    /**
     * 分页参数合理化
     */
    private Boolean reasonable = true;

    public String getOrderBy() {
        if (StringUtils.isEmpty(orderByColumn)) {
            return "";
        }
        return StringUtils.toUnderScoreCase(orderByColumn) + " " + isAsc;
    }

    public Boolean getReasonable() {
        if (StringUtils.isNull(reasonable)) {
            return Boolean.TRUE;
        }
        return reasonable;
    }

}
